<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template_dialog.xhtml">
	<ui:define name="head">
		<title>保护动作分析</title>
		<link rel="stylesheet" href="/resources/bootstrap/css/bootstrap-datetimepicker.min.css" />
		<style>
.active {
	background-color: #0d6aad;
	padding: 0px 10px;
}

.active a {
	color: white;
}

.control-label {
	margin-top: 5px;
}

.form-control[readonly] {
	background-color: white;
}
</style>
	</ui:define>
	<ui:define name="content">
		<div class="row">
			<div class="col-sm-12 " style="padding-left: 30px;">
				<h4 style="font-weight: bold;" id="selectNameH">保护动作分析</h4>
			</div>
			<div class="col-sm-12">
				<div class="col-sm-3 col-md-2">
					<div class="box" id="faultlist">
						<div class="box-header with-border">
							<!-- <h3 class="box-title">故障列表</h3> -->
							<div class="input-group date">
								<input type="text" class="form-control" style="width: 100px" id="beginTime"
									readonly="readonly" placeholder="起始日期" /> <input type="text" class="form-control"
									style="width: 100px" id="endTime" placeholder="终止日期" readonly="readonly" />
								<div class="input-group-btn">
									<button class="btn btn-default" onclick="beginCheck();" title="查询">
										<i class="fa fa-search"></i>
									</button>
									<button class="btn btn-default" title="清除" onclick="begin_end_time_clear();">
										<i class="fa fa-repeat"></i>
									</button>
								</div>
							</div>
						</div>
						<div class="box-body full-content-scroll "></div>
					</div>
				</div>
				<div class="col-sm-9 col-md-10">
					<iframe src="" id="iframePage" frameborder="0" scrolling="no" width='100%'></iframe>
					<div id="noFault" style="display: none">
						<h:form>
							<p:panel header="动作分析" style="text-align: center;font-size:18px;">
								<h:outputText value="无详细信息"></h:outputText>
							</p:panel>
						</h:form>
					</div>
				</div>
			</div>
		</div>
		<h:inputHidden id="lineId" value="#{request.getParameter('selectId')}" />
		<h:inputHidden id="lineName" value="#{request.getParameter('selectName')}" />
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/bootstrap/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
		<script type="text/javascript" src="lineProtectActDialog.js" />
		<script>
			$(function() {
				if ($("#lineName")) {
					var lineName = decodeURIComponent($("#lineName").val());
					$("#selectName").html(lineName + "保护动作分析");
					$("#selectNameH").html(lineName + "保护动作分析");
				}

				$("#beginTime").val(year + "-01-01");
				$("#endTime").val(year + "-" + month + "-" + day);
				$('#beginTime').datetimepicker({
					minView : 2,
					autoclose : true,
					format : 'yyyy-mm-dd'
				});
				$('#endTime').datetimepicker({
					minView : 2,
					autoclose : true,
					format : 'yyyy-mm-dd'
				});
				lineId = $("#lineId").val();
				params = {
					"lineId" : lineId,
					"beginTime" : year + "-01-01",
					"endTime" : year + "-" + month + "-" + day
				};
				$("#faultlist .box-body").empty();
				getLineFaultData(params);
			});

			//对于iframe页面内，静态已知的内容
			function setIframeHeight(iframe) {
				if (iframe) {
					var iframeWin = iframe.contentWindow
							|| iframe.contentDocument.parentWindow;
					if (iframeWin.document.body) {
						iframe.height = iframeWin.document.documentElement.scrollHeight
								|| iframeWin.document.body.scrollHeight;
					}
				}
			};
			//对于iframe页面内，动态内容需要延迟加载
			var iframe = document.getElementById("iframePage");
			function reinitIframe() {
				try {
					var bHeight = iframe.contentWindow.document.body.scrollHeight;
					var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
					var height = Math.max(bHeight, dHeight);
					iframe.height = height;
				} catch (ex) {
				}
			}
			//window.setInterval("reinitIframe()", 500);
			var t1 = window
					.setInterval(
							function() {
								try {
									var bHeight = iframe.contentWindow.document.body.scrollHeight;
									var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
									var height = Math.max(bHeight, dHeight);
								} catch (ex) {
								}
								if (height > 200) {
									iframe.height = height;
									var iMainContentH = document.body.clientHeight;
									$(".full-content-scroll")
											.css(
													{
														"height" : (Number(iMainContentH) - 150)
																+ 'px',
														"overflow-y" : "auto"
													});
									window.clearInterval(t1);
								}
							}, 500);

			/**
			 * 清除时间
			 */
			function begin_end_time_clear() {
				$("#faultlist .box-body").empty();
				$("#beginTime").val(year + "-01-01");
				$("#endTime").val(year + "-" + month + "-" + day);
				params = {
					"lineId" : lineId,
					"beginTime" : year + "-01-01",
					"endTime" : year + "-" + month + "-" + day
				};
				getLineFaultData(params);
			}

			function unescapeF(str) {
				return unescape(str.replace(/\\/g, "%"))
			}
		</script>
	</ui:define>
</ui:composition>